package service

import (
	"context"
	"gitee.com/shuokeyun/merchant-service/internal/domain"

	pb "gitee.com/shuokeyun/merchant-service/api/v1"
)

// MerchantService .
type MerchantService struct {
	pb.UnimplementedMerchantServer
	merchant domain.MerchantUsecase
}

// NewMerchantServer .
func NewMerchantServer(merchant domain.MerchantUsecase) pb.MerchantServer {
	return &MerchantService{
		merchant: merchant,
	}
}

// CreateMerchant .
func (s *MerchantService) CreateMerchant(ctx context.Context, req *pb.CreateMerchantRequest) (*pb.CreateMerchantReply, error) {
	return &pb.CreateMerchantReply{}, nil
}

// UpdateMerchant .
func (s *MerchantService) UpdateMerchant(ctx context.Context, req *pb.UpdateMerchantRequest) (*pb.UpdateMerchantReply, error) {
	return &pb.UpdateMerchantReply{}, nil
}

// DeleteMerchant .
func (s *MerchantService) DeleteMerchant(ctx context.Context, req *pb.DeleteMerchantRequest) (*pb.DeleteMerchantReply, error) {
	return &pb.DeleteMerchantReply{}, nil
}

// GetMerchant .
func (s *MerchantService) GetMerchant(ctx context.Context, req *pb.GetMerchantRequest) (*pb.GetMerchantReply, error) {
	do, err := s.merchant.GetMerchant(ctx, req.GetId(), req.GetFieldMask().GetPaths())
	if err != nil {
		return nil, err
	}
	return merchantDoConvReply(do), nil
}

// ListMerchant .
func (s *MerchantService) ListMerchant(ctx context.Context, req *pb.ListMerchantRequest) (*pb.ListMerchantReply, error) {
	return &pb.ListMerchantReply{}, nil
}
